#re模块--处理正则表达式并对文本进行处理
#
import re
#findall，获取匹配到的所有数据
# text="dsf130429191912015219k13042919591219521Xkk"
# print(re.findall("((\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X))", text))

#match ,从起始位置开始匹配，匹配成功返回一个对象，未匹配成功返回None
# text = "大小逗2B最逗3B欢乐"
# print(re.match("逗\dB",text))  None
# text="逗2B最逗3B欢乐"
# print(re.match("逗\dB",text))


#search,浏览整个字符串去匹配 第一个，未匹配成功返回None
# text = "大小逗2B最逗3B欢乐"
# print(re.search("逗\dB",text))

#sub,替换匹配成功的位置
# text = "逗2B最逗3B欢乐"
# print(re.sub("逗\dB","沙雕", text))
# print(re.sub("逗\dB","沙雕", text,1))

#split ,根据匹配成功的位置进行分割
# text = "逗2B最逗3B欢乐"
# print(re.split("\dB",text))
# print(re.split("\dB",text,1))
# print(re.split("\dB",text)[0])


#finditer
# text = "逗2B最逗3B欢乐"
# data=re.finditer("\dB",text)
# for i in data:
#     content=i.group()
#     print(content)


#正则的命名的分组
# text ="dsf130429191912015219k13042919591219521Xkk"
# data=re.findall("\d{6}(?P<year>\d{4})(?P<moth>\d{2})(?P<day>\d{2})\d{3}",text) #相当于年月日的提取
# print(data)

# text ="dsf130429191912015219k13042919591219521Xkk"
# data=re.finditer("\d{6}(?P<year>\d{4})(?P<moth>\d{2})(?P<day>\d{2})\d{3}",text) #相当于年月日的提取
# for i in data:
#     info=i.groupdict()
#     print(info)

#常见的内置模块：os shuitil sys random hashlib configparser xml josn time datetime re
